package com.douma.linkedlist;


public class ReverseLinkedList {

    // 反转 head 链表，然后返回反转后的新的头节点
    public ListNode reverseList(ListNode head) {
        if (head == null || head.next == null) return head;

        ListNode ret = reverseList(head.next);

        // 反转两个节点
        head.next.next = head;
        head.next = null;

        return ret;
    }
}
